const jwt = require('jsonwebtoken');

exports.getToken = (info) => {
    return jwt.sign(info, 'qwert', { expiresIn: 3000000 });
}


exports.parseToken = (token) => {

    const p = new Promise((resolve, reject) => {
        jwt.verify(token, 'qwert', (err, data) => {
            if (err) {
                resolve({code : 0 , msg : 'token解析失败'});
            }
            else {
                resolve({code : 1 , msg : 'token解析成功'});
            }
        })
    })

    return p
}